<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>trigger(type,[data])</title>
<meta name="keywords" content="jQuery 1.2 API Reference,Visual jQuery 1.2,jQuery doc,jQuery API,jQuery,jQuery 1.2 API 参考文档中文版,中文版" />
<meta name="description" content="jQuery 1.2 API 文档中文版，提供最新版 jQuery 开发帮助。" />
<link rel="stylesheet" type="text/css" href="../../style/jqueryapi.css" />
<script type="text/javascript" src="../../style/lib/jquery126.js"></script>
 </script>
<script type="text/javascript" src="../../style/jqueryapi.js"></script>
<link rel="shortcut icon" href="../../style/img/favicon.ico" />
</head>
<body>
<div id="topnav">
		<a href="http://www.jQuery.com/" title="jQuery官网" target="_blank" class="topnav">jQuery官网</a>
	<span class="topnav">|</span>
	<a href="http://jquery.org.cn/" title="jQuery中文网站" target="_blank" class="topnav">jQuery中文网站</a>
	<span class="topnav">|</span>
	<a href="http://www.cn-cuckoo.com/" title="1.1版译者" target="_blank" class="topnav">为之漫笔</a>
	<span class="topnav">|</span>
	<a href="http://shawphy.com/" title="1.2版翻译整理者" target="_blank" class="topnav">Shawphy</a>
    <span class="topnav">|</span>
	<a href="http://www.51toria.cn" title="CHM文档制作者:一揪" target="_blank" class="topnav">CHM文档制作者</a> 
	<span class="topnav">|</span>
	<a href="http://dl.getdropbox.com/u/81097/jQueryAPI_CHM.CHM" title="" target="_blank" class="topnav">CHM最新版本下载</a> 
</div>
<hr style="color:#595959;" />

<div class="content">
				<h1>trigger(type,[data])</h1>
				<div class="desc"><div>在每一个匹配的元素上触发某类事件。</div> <div class="longdesc"><p>这个函数也会导致浏览器同名的默认行为的执行。比如，如果用trigger()触发一个'submit'，则同样会导致浏览器提交表单。如果要阻止这种默认行为，应返回false。</p><p>你也可以触发由bind()注册的自定义事件</p></div></div><hr />
				<div class="desc"><div>Trigger a type of event on every matched element.</div> <div class="longdesc"><p>This will also cause the default action of the browser with the same name (if one exists) to be executed. For example, passing 'submit' to the trigger() function will also cause the browser to submit the form. This default action can be prevented by returning false from one of the functions bound to the event.</p><p>You can also trigger custom events registered with bind.</p></div></div>
				<h2>返回值</h2>
				<p class="indent">jQuery</p>
				<h2>参数</h2>
				<p class="indent"><strong>type </strong>(String) : 要触发的事件类型</p>
				<p class="indent"><strong>data </strong>(Array) : (可选)传递给事件处理函数的附加参数</p>
				<h2>示例</h2>
				<p class="indent">
					提交第一个表单，但不用submit()
				</p>
				<p class="indent"><strong>jQuery 代码:</strong></p>
				<div class="code">
					$("form:first").trigger("submit") 
				</div>
				<hr />
				<p class="indent">
					给一个事件传递参数
				</p>
				<p class="indent"><strong>jQuery 代码:</strong></p>
				<div class="code">
					$("p").click( function (event, a, b) {<br/>
&nbsp; // 一个普通的点击事件时，a和b是undefined类型<br/>
&nbsp; // 如果用下面的语句触发，那么a指向"foo",而b指向"bar"<br/>
} ).trigger("click", ["foo", "bar"]); 
				</div>
				<hr />
				<p class="indent">
					下面的代码可以显示一个"Hello World"
				</p>
				<p class="indent"><strong>jQuery 代码:</strong></p>
				<div class="code">
					$("p").bind("myEvent", function (event, message1, message2) {<br/>
&nbsp; alert(message1 + ' ' + message2);<br/>
});<br/>
$("p").trigger("myEvent", ["Hello","World!"]); 
				</div>
			</div>
            
</body>
</html>
